#pragma once
#include <opencv2/opencv.hpp>
#include "drawRect.h"
#include "opencv2/ml.hpp"
#include "debug.h"

using namespace cv;
using namespace std;
using namespace ml;

class buff_detect
{
public:

	//读取xml文件
	buff_detect(int& color);
	
	//对获取的图像进行颜色通道相减
	void color_buff(Mat image, int color);

	//能量机关的识别任务
	int BuffDetectTask(Mat& image, float& angle, struct logo& center_R);
	
	//获取装甲板的位置
	void buff_detection(Mat& img, vector<RotatedRect>& target_R, vector<RotatedRect>& target_armor);
	
	//机器学习识别R形图片
	void machineLearning(Mat image, vector<RotatedRect> R, vector<RotatedRect>& final_R, Ptr<SVM> svm);

	//获取待识别的R
	void get_energy_center(Mat image, RotatedRect father, RotatedRect son, vector<RotatedRect> rect, vector<RotatedRect>& R);

private:

	string modelpath1 = "xml/svmR27.xml";
	Ptr<SVM> svm1 = StatModel::load<SVM>(modelpath1);//����Ѱ��R��xml

	drawbox box;	

	Mat gray_dst;
	Mat dst;

	int svmWidth = 48;
	int svmHeight = 48;
	
	int num = 0;
	int son_num = 0;

	int f_s_area_max = 0;
	int f_s_area_min = 0;
	int father_area_min = 0;
	int son_area_min = 0;
	int father_area_max = 0;
	int son_area_max = 0;


	int threshValue = 0;
	int gray_threshValue = 0;
	int gray_dilate_size = 0;
	int dilate_size = 0;
	int erode_size = 0;
	int say_area = 0;
	
	bool ok = false;
	bool get_r = false;
};
	
//用于储存能量机关的信息
struct logo
{
	float x = 0;//中心x坐标
	float y = 0;//中心y坐标
	float r = 0;//能量机关的半径
};
